package com.battle.service.controller.web;

import com.battle.pojo.param.questionBankDetails.*;
import com.battle.pojo.vo.questionBankDetails.*;
import com.battle.service.service.in.*;
import nirvana.core.domains.vo.PageResult;
import nirvana.core.domains.vo.ApiResult;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

import java.util.List;

/**
 * web/题目管理
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 */
@RestController
@RequestMapping("/questionBankDetails/web")
public class QuestionBankDetailsWebController {

    private final QuestionBankDetailsService service;

    public QuestionBankDetailsWebController(QuestionBankDetailsService service) {
        this.service = service;
    }


    /**
     * 创建题目管理
     *
     * @param param
     * @return
     */
    @PostMapping("/createQuestionBankDetails")
    public ApiResult createQuestionBankDetails(@RequestBody @Valid CreateQuestionBankDetailsParam param) {
        service.createQuestionBankDetails(param);
        return ApiResult.ok();
    }

    /**
     * 批量创建题目管理
     *
     * @param param
     * @return
     */
    @PostMapping("/bathCreateQuestionBankDetails")
    public ApiResult bathCreateQuestionBankDetails(@RequestBody @Valid BathCreateQuestionBankDetailsParam param) {
        service.bathCreateQuestionBankDetails(param);
        return ApiResult.ok();
    }


    /**
     * 修改题目管理
     *
     * @param param
     */
    @PutMapping("/editQuestionBankDetails")
    public ApiResult editQuestionBankDetails(@RequestBody @Valid EditQuestionBankDetailsParam param) {
        service.editQuestionBankDetails(param);
        return ApiResult.ok();
    }

    /**
     * 移除题目管理
     *
     * @param id
     */
    @DeleteMapping("/removeQuestionBankDetails")
    public ApiResult removeQuestionBankDetails(@RequestParam("id") Long id) {
        service.removeQuestionBankDetails(id);
        return ApiResult.ok();
    }

    /**
     * 启动/禁用题目管理
     *
     * @param id
     */
    @GetMapping("/enabledQuestionBankDetails")
    public ApiResult enabledQuestionBankDetails(@RequestParam("id") Long id) {
        service.enabledQuestionBankDetails(id);
        return ApiResult.ok();
    }

    /**
     * 获取题目管理详情
     *
     * @param id
     * @return
     */
    @GetMapping("/getQuestionBankDetails")
    public ApiResult<GetQuestionBankDetailsVo> getQuestionBankDetails(@RequestParam("id") Long id) {
        GetQuestionBankDetailsVo vo = service.getQuestionBankDetails(id);
        return ApiResult.ok(vo);
    }

    /**
     * 获取题目管理列表
     *
     * @param param
     * @return
     */
    @PostMapping("/getQuestionBankDetailsList")
    public ApiResult<PageResult<GetQuestionBankDetailsListVo>> getQuestionBankDetailsList(@RequestBody GetQuestionBankDetailsListParam param) {
        PageResult<GetQuestionBankDetailsListVo> result = service.getQuestionBankDetailsList(param);
        return ApiResult.ok(result);
    }


    /**
     * 获取题目管理下拉列表
     *
     * @return
     */
    @PostMapping("/getQuestionBankDetailsDownList")
    public ApiResult<List<GetQuestionBankDetailsDownListVo>> getQuestionBankDetailsDownList(@RequestBody(required = false) @Valid GetQuestionBankDetailsDownListParam param) {
        List<GetQuestionBankDetailsDownListVo> list = service.getQuestionBankDetailsDownList(param);
        return ApiResult.ok(list);
    }


}

